#include "stdafx.h"
#include "truetype_hhea.h"
#include "truetype.h"

void truetype_hhea(truetype_t * tt, tt_table_t * table)
{
	if(!tt || !tt->stream || !table || table->type != tt_table_type_hhea)
		return ;
	base_stream_t * stream = tt->stream;

	tt_hhea_t hhea;
	stream->seeker(stream, table->offset, stream_seek_begin);
	stream->reader(stream, &hhea, sizeof(tt_hhea_t));
	uint_32 hmtx_count = 0;
#ifdef TT_SMALL_ENDIAN
	hmtx_count = confirm_big_word(hhea.hmtx_count);
	tt->ascent = confirm_big_short(hhea.ascend);
	tt->descent = confirm_big_short(hhea.descent);
#else
	hmtx_count = hhea.hmtx_count;
	tt->ascent = hhea.ascent;
	tt->descent = hhea.descent;
#endif // TT_SMALL_ENDIAN
	tt->hmtx.base_count = hmtx_count;
}
